// 笔试强训:DNA序列

#include <iostream>
#include <vector>
using namespace std;

int main() {
    string str; cin >> str;
    int len = 0, ans = 0, ansRate = 0; cin >> len;
    int n = str.size();

    int num = 0;
    for(int i = 0; i < len; i++)
    {
        if(str[i] == 'G' || str[i] == 'C')
            num++;
    }
    ansRate = num;

    for(int i = 1; i < n - len + 1; i++)
    {
        if(str[i - 1] == 'G' || str[i - 1] == 'C')
            num--;
        if(str[i + len - 1] == 'G' || str[i + len - 1] == 'C')
            num++;

        if(num > ansRate)
        {
            ansRate = num;
            ans = i;
        }
    }
    for(int i = 0; i < len; i++)
    {
        cout << str[ans + i];
    }
    cout << endl;
}
